package logic.ships.resourceShip;

import com.jme.math.Vector3f;
import com.jme.scene.TriMesh;

import logic.slots.NodeSlot;

public class ResourceSlot extends NodeSlot {
	
	private static final long serialVersionUID = 1L;
	
	private TriMesh drop, out;
	private ResourceShip ship;
	private Vector3f outLoc, dropLoc, dir;
	
	public ResourceSlot(TriMesh drop, TriMesh out, ResourceShip ship) {
		super("ResourceSlot", ship, out);
		this.drop = drop;
		this.out = out;
		this.ship = ship;
	}
	
	@Override
	public void checkSlots() {
		outLoc = getLocalPos(out);
		dropLoc = getLocalPos(drop);
		dir = outLoc.subtract(dropLoc);
		
		out.removeFromParent();
		removeFromParent();
	}
	
	public Vector3f getMoveLocation() {
		if(dropLoc == null) return null;
		return ship.localToWorld(dropLoc.add(dir.mult(4f)), new Vector3f());
	}
}